/**
 * Created by Administrator on 2022/8/7.
 */
public class Test {
    /*public static void main(String[] args) {
        *//*创建方法求两个数的最大值max2，随后再写一个求3个数的最大值的函数max3。
        要求：在max3这个函数中，调用max2函数，来实现3个数的最大值计算*//*
        int a = 1;
        int b = 2;
        int c = 3;
        int ret2 = max2(a,b);
        System.out.println(ret2);
        int ret3 =max3(a,b,c);
        System.out.println(ret3);
    }
    public static int max2(int num1,int num2){
        return (num1 > num2) ? num1 : num2;
    }
    public static int max3(int num1,int num2,int num3){
        int max = max2(num1,num2);
        return (max > num3) ? max : num3;
    }*/

    /*public static void main(String[] args) {
        //求 N 的阶乘
        int n = 6;
        int ret = fac(n);
        System.out.println(ret);
    }
    public static int fac(int n){
        int f = 1;
        for (int i = 1; i <= n; i++) {
            f *= i;
        }
        return f;
    }*/

    /*public static void main(String[] args) {
        //求1！+2！+3！+4！+........+n!的和
        int n = 3;
        int ret = fac(n);
        System.out.println(ret);
    }
    public static int fac(int n){
        int f = 1;
        int sum = 0;
        for (int i = 1; i <= n; i++) {
            for (int j = 1; j <= i; j++) {
                f *= j;
            }
            sum += f;
            f = 1;
        }
        return sum;
    }*/

    /*public static void main(String[] args) {
        //求斐波那契数列的第n项。(迭代实现)
        int n = 6;
        int ret = fib(n);
        System.out.println(ret);
    }
    public static int fib(int n){
        int n1 = 1;
        int n2 = 1;
        int n3 = 0;
        for(int i = 3;i <= n;i++){
            n3 = n1 + n2;
            n1 = n2;
            n2 = n3;
        }
        return n3;
    }*/

    /*public static void main(String[] args) {
       //求和的重载 在同一个类中,分别定义求两个整数的方法 和 三个小数之和的方法。
        int a = 1;
        int b = 2;
        int ret = sum(a,b);
        System.out.println(ret);
        double n1 = 1.7;
        double n2 = 2.6;
        double n3 = 3.6;
        double ret2 = sum(n1,n2,n3);
        System.out.println(ret2);
    }
    public static int sum(int a,int b){
        return a + b;
    }
    public static double sum(double num1,double num2,double num3){
        return num1 + num2 + num3;
    }*/

    public static void main(String[] args) {
        //求最大值方法的重载
        //在同一个类中定义多个方法：要求不仅可以求2个整数的最大值，还可以求3个小数的最大值
        int a = 1;
        int b = 2;
        int c = 3;
        int ret = max(a,b);
        System.out.println(ret);
        int ret2 = max(a,b,c);
        System.out.println(ret2);
    }
    public static int max(int a,int b){
        return (a > b) ? a : b;
    }
    public static int max(int a,int b,int c){
        int ret = max(a,b);
        return (ret > c) ? ret : c;
    }
}
